<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue中JS动画与velocity.js</title>
    <script src="../lib/vue.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/velocity.min.js" type="text/javascript"></script>
</head>
<body>
<!--    添加颜色变化的动态效果-->
<div id="root">
    <transition
            name="fade"
            @before-enter="handleBeforeEnter"
            @enter="handleEnter"
            @after-enter="handleAfterEnter"
    >
        <div v-if="show">hello world</div>
    </transition>
    <button @click="handleClick">切换</button>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el: "#root",
        data: {
            show: true
        },
        methods: {
            handleClick: function () {
                this.show = !this.show
            },
            handleBeforeEnter: function (el) {
                el.style.opacity = 0
            },
            handleEnter: function (el, done) {
                Velocity(el, {opacity: 1}, {duration: 1000,complete:done})
            },
            handleAfterEnter: function (el) {
                console.log("动画结束")
            }
        },
    });
</script>
<style type="text/css">
</style>
</body>
</html>
